# This file is a part of the open-eBackup project.
# This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
# If a copy of the MPL was not distributed with this file, You can obtain one at
# http://mozilla.org/MPL/2.0/.
#
# Copyright (c) [2024] Huawei Technologies Co.,Ltd.
#
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
from enum import Enum, IntEnum
from app.common.enums.resource_enum import ResourceSubTypeEnum


class GenerationType(Enum):
    # The copy is generated by backup
    BY_BACKUP = "Backup"
    # The copy is generated by cloud archive
    BY_CLOUD_ARCHIVE = "CloudArchive"
    # The copy is generated by tape archive
    BY_TAPE_ARCHIVE = "TapeArchive"
    # The copy is generated by live mount
    BY_LIVE_MOUNTE = "live_mount"
    # The copy is generated by replicated
    BY_REPLICATED = "Replicated"
    # The copy is generated by Imported
    BY_IMPORTED = "Imported"
    # The copy is generated by common interface backup
    BY_COMMON_INTERFACE_BACKUP = "CommonInterfaceBackup"
    # dws下载副本，dws归档到磁带的副本需要下载到A8000才能恢复，其他应用不用下载可以直接恢复
    BY_DOWNLOAD = "Download"
    # 反向复制
    BY_REVERSE_REPLICATION = "ReverseReplication"
    # 级联复制
    BY_CASCADED_REPLICATION = "CascadedReplication"

    @classmethod
    def get_generated_by_sub_type(cls, sub_type):
        RESOURCE_SUB_TYPE_GENERATED_BY = {ResourceSubTypeEnum.Replica.value: GenerationType.BY_REPLICATED.value,
                                          ResourceSubTypeEnum.ImportCopy.value:
                                              GenerationType.BY_COMMON_INTERFACE_BACKUP.value}
        return RESOURCE_SUB_TYPE_GENERATED_BY.get(sub_type, cls.BY_BACKUP.value)


class CopyFormatEnum(IntEnum):
    # 原生格式
    INNER_SNAPSHOT = 0
    # 非原生格式
    INNER_DIRECTORY = 1
    # 外部格式
    EXTERNAL = 2


class CopyVerifyStatusEnum(IntEnum):
    # 未校验
    NOT_VERIFY = 0
    # 校验失败
    VERIFY_FAILED = 1
    # 校验成功
    VERIFY_SUCCESS = 2
    # 校验文件不存在
    VERIFY_FILE_NOT_EXIST = 3
